<!doctype html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Document</title>
    <style>
        body {
            margin: 0;
        }

        .wrap {
            width: 200px;
            height: 200px;
            padding: 200px;
            border: 1px solid #ccc;
            margin: 0 auto;
            perspective: 800px;
        }

        .box {
            width: 200px;
            height: 200px;
            position: relative;
            transform-style: preserve-3d;
            transform-origin: center center;
            transform: translateZ(-100px);
        }

        .box div {
            position: absolute;
            width: 100%;
            height: 100%;
            line-height: 200px;
            text-align: center;
            font-size: 80px;
            color: #fff;
            left: 0;
            top: 0;
            opacity: 0.5;
        }

        .box div:nth-child(1) {
            background-color: darkorange;
            transform-origin: top;
            transform: translateZ(-100px) rotateX(90deg);
        }

        .box div:nth-child(2) {
            background-color: #d43f3a;
            transform-origin: left;
            transform: translateZ(-100px) rotateY(-90deg);
        }

        .box div:nth-child(3) {
            background-color: aquamarine;
            transform: translateZ(100px);
        }

        .box div:nth-child(4) {
            background-color: blueviolet;
            transform-origin: right;
            transform: translateZ(-100px) rotateY(90deg);
        }

        .box div:nth-child(5) {
            background-color: darkkhaki;
            transform-origin: bottom;
            transform: translateZ(-100px) rotateX(-90deg);
        }

        .box div:nth-child(6) {
            background-color: pink;
            transform: translateZ(-100px) rotateX(180deg);
        }
    </style>
</head>
<body>
<div id="wrap" class="wrap">
    <div id="box" class="box">
        <div>1</div>
        <div>2</div>
        <div>3</div>
        <div>4</div>
        <div>5</div>
        <div>6</div>
    </div>
</div>
<script>
    var boxE = document.querySelector('#box'),
            getRotateX = (function () {
                var X = 0;
                return function () {
                    X += 1;

                    if (X > 360) {
                        X = 1;
                    }

                    return X;
                }
            })(),
            getRotateY = (function () {
                var Y = 1;
                return function () {
                    Y += 1;

                    if (Y > 360) {
                        Y = 1;
                    }

                    return Y;
                }
            })();

    var t = setInterval(function () {
        boxE.style.transform = 'translateZ(-100px) rotateX(' + getRotateX() + 'deg) rotateY(' + getRotateY() + 'deg)';
    }, 16);

</script>
</body>
</html>